<template>
  <div>
    <!-- <div class="ser_div">
      <el-row>
        <el-col>
           <span>{{chanpin_name}}</span>
        </el-col>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 型号 </el-col>
            <el-col :span="16">
              <el-select
                filterable
                v-model="model_number_id"
                placeholder="请选择型号"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in ModelNumberList"
                  :key="index"
                  :label="item.model_number"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-button @click="search(0)" class="add_btn" icon="el-icon-search"
            >查询</el-button
          >
          <el-button @click="add_product" icon="el-icon-plus" class="add_btn">批量添加到成品库</el-button>
        </el-col>
      </el-row>
    </div> -->
    <el-table :data="dataList" v-loading="loading" style="width: 100%;margin-top: 20px;" border>
      <el-table-column label="产品">
        <template slot-scope="scope">
          {{ scope.row.product?scope.row.product.product_name:'' }}
        </template>
      </el-table-column>
      
      <el-table-column label="数量">
        <template slot-scope="scope">
          {{ scope.row.count }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <!-- 床头 -->
          <el-button slot="reference" type="tetx" v-if="scope.row.modelid==5" @click="push_xinghao(scope.row.product_id)">详情</el-button>
            <!-- 床头柜 -->
           <el-button slot="reference" type="tetx" v-if="scope.row.modelid==7" @click="push_yanse(scope.row.product_id)">详情</el-button>
           <!--  床板 帮-->
          <el-button slot="reference" type="tetx" v-if="scope.row.modelid==3||scope.row.modelid==4" @click="push_guige(scope.row.product_id)">详情</el-button>
         

        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        @prev-click="prev"
        @next-click="next"
        :current-page.sync="pagination.page"
        :page-size="pagination.per_page"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getSemiFinishProductInfo
} from "@/api/product/index";
export default {
  data() {
    return {

      loading: true,
      dataList: [],
      pagination: {
        per_page: 10,
        page: 1,
      },
      total: 0,
      warehouse_id:''
    };
  },
  mounted() {
    this.warehouse_id=this.$route.query.data
    this.getlist(this.$route.query.data);
  },
  methods: {
    push_xinghao(id){
      this.$router.push({
        name: "index_more_xinghao",
        path: "/index_more_xinghao",
        query:{
          data:  this.warehouse_id,
          product_id:id
        }
      });
    },
    push_yanse(id){
      this.$router.push({
        name: "index_more_yanse",
        path: "/index_more_yanse",
        query:{
          data: this.warehouse_id,
          product_id:id
        }
      });
    },
    push_guige(id){
      this.$router.push({
        name: "index_more_guige",
        path: "/index_more_guige",
        query:{
          data: this.warehouse_id,
          product_id:id
        }
      });
    },
    // 型号列表
    getModel() {
      getModelNumberList({product_id:this.product_id}).then((res) => {
        if (res.code == 200) {
          this.ModelNumberList = res.data.data;
        }
      });
    },
    getlist() {
      getSemiFinishProductInfo({page_name:'product',warehouse_id:this.warehouse_id,...this.pagination}).then((res) => {
        if (res.code == 200) {
          this.dataList = res.data.data;
          this.total = res.data.total;
          this.loading = false;
        }
      });
    },
    handleSizeChange(val) {
      console.log(val);
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.page = val;
      this.getlist();
    },
    prev() {
      this.pagination.page = this.pagination.page - 1;
      this.getlist();
    },
    next() {
      console.log("ss");
      this.pagination.page = this.pagination.page + 1;
      this.getlist();
    },
  },
};
</script>

<style scoped>
.d {
  color: black !important;
}
.el-table{
  margin-top:0px;
}
</style>
